use std::path::PathBuf;
use crate::fio;
use parking_lot::RwLock;
use std::sync::Arc;
use crate::errors::{Result};
use crate::data::log_record::LogRecord;
// 数据文件
pub struct DataFile {
    file_id: Arc<RwLock<u32>>, // 文件id
    write_off: Arc<RwLock<u64>>, //当前写偏移,记录该数据文件写到哪
    io_manager: Box<dyn fio::IOManager>, // IO管理接口
}

impl DataFile{
    pub fn new(dir_path: PathBuf, file_id: u32) -> Result<DataFile>{
        todo!()
    }
    pub fn get_write_off(&self) -> u64 {
        let read_guard = self.write_off.read();
        *read_guard
    }
    pub fn get_file_id(&self) -> u32 {
        let read_guard = self.file_id.read();
        *read_guard
    }
    pub fn sync(&self) -> Result<()>{
        todo!()
    }
    pub fn write(&self, buf: &[u8]) -> Result<u64>{
        todo!()
    }
    // pub fn read(&self, off: u64, buf: &mut [u8]) -> Result<u64>{
    //     todo!()
    // }
    pub fn read_log_record(&self, off: u64) -> Result<LogRecord>{
        todo!()
    }

}
